from LoggerBase import log
import requests
import json, time

appkey = "173aee16726d444bb1f61025dd9cef74"
sid = "36576"
pid = "mm_55844929_1958550315_110731150452"
rid = "3114449337"


def convert_tao_id(tkl):
    url = "https://api.zhetaoke.com:10001/api/open_shangpin_id.ashx"

    formData = "appkey=%s&sid=%s&content=%s&type=1&pid=%s&relation_id=%s" % (appkey, sid, tkl, pid, rid)
    # print(formData)
    con = requests.get(url=url + "?" + formData)
    res = con.text
    print(res)
    if con.status_code == 200 and "item_id" in res:

        product_messages = json.loads(res)
        print(product_messages)
        return product_messages
    else:
        return False


if __name__ == "__main__":
    content = "【淘宝】https://m.tb.cn/h.gka5oo6XVK0GkdC?tk=387y3WmWRGp CA6496 「笔记本电脑防窥膜适用戴尔华为联想Thinkpad苹果MacBook戴尔华为小米屏幕保护膜14/15.6寸台式显示器防窥屏膜」点击链接直接打开 或者 淘宝搜索直接打开"

    mess = convert_tao_id(
        "【淘宝】https://m.tb.cn/h.gka5oo6XVK0GkdC?tk=387y3WmWRGp CA6496 「笔记本电脑防窥膜适用戴尔华为联想Thinkpad苹果MacBook戴尔华为小米屏幕保护膜14/15.6寸台式显示器防窥屏膜」点击链接直接打开 或者 淘宝搜索直接打开")
    print(mess)
